package
{
	import mx.validators.ValidationResult;
	import mx.validators.Validator;

	public class MyValidator extends Validator
	{
		//define a array to store results
		private var results:Array;

		public function MyValidator()
		{
			super();
		}

		override protected function doValidation(value:Object):Array{
			var s:String = value as String;
			//clear array
			results=[];
			results = super.doValidation(value);
			//set the new rule for validation
			if(s.length>6){
				results.push(new ValidationResult(true,"text","StringIsTooLong","String is more than 6 chars"));
			}
			if(s.search("a") != -1 || s.search("b") != -1){
				results.push(new ValidationResult(true,"text","noAB","'a','b' are invalid chars"));
			}
//			if(results.length>0){
//				return results;
//			}
			return results;
		}

	}
}

